package com.extra_archive.project.iisu.view 
{
	import com.extra_archive.framework.core.mvc.controller.IController;
	import com.extra_archive.framework.core.mvc.model.IModel;
	import com.extra_archive.framework.core.mvc.view.ComponentView;
	import com.extra_archive.framework.utils.TextFieldUtils;
	import com.extra_archive.project.iisu.model.IBasicModel;

	import flash.events.Event;
	import flash.system.System;
	import flash.text.TextField;
	import flash.text.TextFormat;

	/**
	 * @author vkimone
	 */
	public class BasicDebugView extends ComponentView 
	{
		protected var _result : TextField;
		
		protected var _memMax : Number = 0;

		public function BasicDebugView(model : IModel = null, controller : IController = null)
		{
			super(model, controller);
			
			createTextField();
		}
		
		//--------------------------------------------------------------------------
		//
		//    Public Methods
		//
		//--------------------------------------------------------------------------
		
		override public function update(event : Event = null) : void 
		{
			_result.text = "";
			
			var mem : Number = (System.totalMemory / 1024 / 1024);
			_memMax = Math.max(_memMax, mem);
			
			_result.appendText("Mem Max : " + _memMax.toFixed(2) + "MB" +  "\n");
			_result.appendText("isGestureControl : " + IBasicModel(_model).gesture.isGestureControl + "\n");
		}

		//--------------------------------------------------------------------------
		//
		//    Private Methods
		//
		//--------------------------------------------------------------------------

		private function createTextField() : void 
		{
			var format : TextFormat = new TextFormat("Arial");
			format.leading = -2;
			format.size = 12;
			format.color = 0xffffff;
			
			_result = TextFieldUtils.create(300, 150, format, "left", "dynamic", false);
			_result.backgroundColor = 0x000000;
			_result.background = true;
			
			addChild(_result);
		}
		
	}
}
